﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using SRP_LibBusinessRules;
using SRP_LibBusinessEntity;

namespace SRPCENTRIA.ws_appPrivada
{
    public partial class wManFormatCorreo : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string codFormat;
                Session["codFormat"] = Request.QueryString["idFormat"];
                codFormat= Request.QueryString["idFormat"].ToString();

                DataTable dt = new DataTable();
                NFormatCorreo FormatCorreo = new NFormatCorreo();
                dt = FormatCorreo.MostrarFormato(Convert.ToInt16(codFormat));
                txtAsunto.Text = dt.Rows[0].ItemArray[dt.Columns["VFOR_TITULO_CORREO"].Ordinal].ToString();
                txtContenido.Text = dt.Rows[0].ItemArray[dt.Columns["VFOR_DETALLE_CORREO"].Ordinal].ToString();


            }
        }

        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            NFormatCorreo NFormatCorreo = new NFormatCorreo();
            string codFormat;
            Session["codFormat"] = Request.QueryString["idFormat"];
            codFormat = Request.QueryString["idFormat"].ToString();

            if (NFormatCorreo.UpdateFormato(Convert.ToInt16(codFormat), txtAsunto.Text.Trim().ToString(), txtContenido.Text.Trim().ToString()) == 1)
            {
                EscribirScriptManager("Se Actualizo con éxito");
                //lblError.Visible = true;
                //lblError.Text = "Se Actualizo con éxito";
            }
            else
            {
                EscribirScriptManager("No se pudo insertar");
                //lblError.Visible = true;
                //lblError.Text = "No se pudo insertar";
            }
             
        }

        protected void btnRetornar_Click(object sender, EventArgs e)
        {
            //Session.Abandon();
            //Response.Redirect("wManParametria.aspx", true);
        }
    }
}